package in.indijava.scjp5questions;

public enum InlineEnumOverriding {

	A(1),
	B(2) { 
		// THIS ANONYMOUS CODE BLOCK, 
		// HELPS TO HANDLE EXCEPTIONAL CASES IN 'B'
		// *** ONLY METHODS CAN BE OVERRIDEN ***
		@Override
		public int getK() {
			return k*k*k;
		}},
	C(3);
	
	int k; // must be accessible from inner classes
	
	private InlineEnumOverriding(int k) {
		this.k = k;
	}
	
	public int getK() {
		return k*k;
	}
	
	public void setK(int k) {
		this.k = k;
	}
	
	public static void main(String[] args) {
		System.out.println(A.getK());
		System.out.println(B.getK());
		System.out.println(C.getK());
	}
}
